package com.mall.service.homepage.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mall.commons.common.CommonPage;
import com.mall.model.domain.SmsHomeRecommendProduct;
import com.mall.model.domain.SmsHomeRecommendSubject;
import com.mall.service.homepage.mapper.HomeRecommendProductMapper;
import com.mall.service.homepage.mapper.HomeRecommendSubjectMapper;
import com.mall.service.homepage.service.HomeRecommendProductService;
import com.mall.service.homepage.service.HomeRecommendSubjectService;
import org.springframework.stereotype.Service;

@Service
public class HomeRecommendSubjectServiceImpl extends ServiceImpl<HomeRecommendSubjectMapper, SmsHomeRecommendSubject> implements HomeRecommendSubjectService {
    @Override
    public CommonPage<SmsHomeRecommendSubject> findByPage(Integer pageNum, Integer pageSize, String subjectName, Integer recommendStatus) {
        Page<SmsHomeRecommendSubject> page = new Page<>(pageNum, pageSize);
        LambdaQueryWrapper<SmsHomeRecommendSubject> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(subjectName!=null,SmsHomeRecommendSubject::getSubjectName,subjectName);
        queryWrapper.like(recommendStatus!=null,SmsHomeRecommendSubject::getRecommendStatus,recommendStatus);
        this.page(page,queryWrapper);
        CommonPage <SmsHomeRecommendSubject> commonPage= CommonPage.getPage(page);

        return commonPage;
    }
}
